var layedit;
var $;
var layer;
var form;
layui.use(['layedit','layer','form'], function() {
    layedit = layui.layedit;
    $=layui.jquery;
    form=layui.form;
    layer=layui.layer

    //页面刷新
    $("#btn_1").on('click',function(){
        location.reload(true);
    })

    //设置图片接口
    layedit.set({
        uploadImage: {
            url: '/SyteacherSelController/getimg',
            type: 'post',
        }
    });
    var index_ed = layedit.build('demo'); //建立编辑器

    //保存草稿
    $("#add_1").on("click",function(){
        var content=layedit.getContent(index_ed);
        var title=$("#title_id").val();
        var type1=$("#type_id").val();
        AddComment(content,title,type1,2);
    })


    $("#btn_2").on('click',function(){
        var content=layedit.getContent(index_ed);
        var title=$("#title_id").val();
        var type1=$("#forumid").val();
        AddComment(content,title,type1,5);
    })

    $("#icon_id").on('click',function(){
        layer.open({
            type:2,
            title:"类型分类",
            area:['800px','600px'],
            shade:0,
            maxmin:true,
            offset:'auto',
            content:"CommentType.html",
        });
        window.layer_1=layer;
    })

    $("#type_id").on("click",function(){
        layer.open({
            type:2,
            title:"分类详情",
            area:['600px','400px'],
            shade:0.4,
            offset:'auto',
            content:"ForumTree.html",
            success:function(layero,index){
            }
        })
        window.layer_4=layer;
    })
})
    function AddComment(content,title,type,details){
        $.ajax({
            url:"/SyteacherSelController/addCommentAct",
            type:'post',
            dataType:"json",
            data:{"content":content,"title":title,"typeid":type,"userid":1,"details":details},
            success:function(data){
                location.reload(true);
            }
        })
    }